home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / holdit10.zip / HOLDIT.PAS < prev   
Pascal/Delphi Source File  |  1993-05-05  |  1KB  |  58 lines

  1. PROGRAM HoldIt;
  2.  
  3. Uses Crt, Dos;
  4.  
  5. VAR i, k            : INTEGER;
  6.     time1, time2    : LONGINT;
  7.     ch              : CHAR;
  8.     str             : STRING;
  9.     stdout          : TEXT;
  10.     returncode      : BYTE;
  11.     h1, m1, s1, hu1 : WORD;
  12.  
  13. Begin
  14.   If ParamCount >= 1 Then
  15.   Begin
  16.     str := Paramstr(1);
  17.     Val(str, i, k);
  18.     If k <> 0 Then
  19.     Begin
  20.       WriteLn(Chr(7));       {beep twice}
  21.       WriteLn(Chr(7));
  22.       WriteLn('Wrong parameter setting !!');
  23.       i := 0;
  24.     End
  25.   End
  26.   Else i := 0;
  27.   Assign(stdout, '');                                {Assign standard output}
  28.   Rewrite(stdout);
  29.   WriteLn(stdout, 'Press any key to continue... ');
  30.   GetTime(h1, m1, s1, hu1);
  31.   time1 := 3600 * h1 + 60 * m1 + s1;
  32.   time2 := time1;
  33.   While (NOT KeyPressed) AND (ABS(time1 - time2) <= i) Do
  34.   Begin
  35.     GetTime(h1, m1, s1, hu1);
  36.     time2 := 3600 * h1 + 60 * m1 + s1;
  37.     If i = 0 Then time2 := time1;
  38.   End;
  39.   If KeyPressed Then
  40.   Begin
  41.     ch := ReadKey;
  42.     Case ch Of
  43.       '1'..'9': returncode := Ord(ch) - 48;   {code is 1..9 for keys 1..9}
  44.       '0'     : returncode := 10;             {code is 10 for key 0}
  45.       Chr(27) : returncode := 200;            {code is 200 for ESC}
  46.     Else
  47.       returncode := 100;                      {code is 100 for any other key}
  48.     End;
  49.   End
  50.   Else
  51.     returncode := 0;                          {code is 0 if timeout true}
  52.   ASM
  53.    mov ah, 4ch
  54.    mov al, returncode
  55.    int 21h
  56.   End;
  57. End.
  58.